<template>
  <div class="container mt15">
    <el-card>
      <el-button type="primary" icon="el-icon-document-add" class="mb20" @click="editShow('新增')">新增</el-button>
      <el-table
        :key="tableKey"
        v-loading="listLoading"
        :data="list"
        fit
        stripe
        highlight-current-row
        style="width: 100%;"
      >
        <el-table-column label="id" align="center" />
        <el-table-column label="标题" align="center" />
        <el-table-column label="链接" align="center" />
        <el-table-column label="是否新页面打开" align="center" />
        <el-table-column label="状态" align="center" />
        <el-table-column label="操作" align="center">
          <el-button type="text" @click="editShow('编辑')">编辑</el-button>
          <el-button type="text">删除</el-button>
          <el-button type="text">置顶</el-button>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        prev-text="上一页"
        next-text="下一页"
        layout="prev, pager, next, jumper"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.limit"
        @pagination="getList"
      />
    </el-card>

    <editn-notice ref="editnNotice" />
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'
import editnNotice from './components/edit-notice'
export default {
  name: '',
  components: { Pagination, editnNotice },
  props: {},
  data() {
    return {
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 20,
        importance: undefined,
        title: undefined,
        type: undefined,
        sort: '+id'
      }
    }
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() { this.getList() },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  // 销毁
  destroyed() {},
  // 方法
  methods: {

    getList() {
      this.listLoading = true
      this.list = [''],
      this.total = 1
      setTimeout(() => {
        this.listLoading = false
      }, 1.5 * 1000)
    },
    editShow(title) {
      this.$refs.editnNotice.show(title)
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
